var wayid = GetQueryString('waynumid');
var userid = GetQueryString('uid');
if(wayid){
	$(".cz").css('display',"none");
	$(".gs").css('display',"none");
	$(".lxr").css('display',"none");
	//同盾+渠道
	datatype = {'apt_type':'','userid':userid,"wayid":wayid};
	//百融+渠道
	dataname = {'api_name':'','userid':userid,"wayid":wayid};
}else{
	//同盾+订单
	datatype = {'apt_type':'','userid':userid};
	//百融+订单
	dataname = {'api_name':'','userid':userid};
}
function angdeapi(apitype,response_fun) {
	datatype.apt_type = apitype;
	post('/Admin/Credit/bodyGuard',datatype,response_fun,'json');
}
function  onehundredapi(api_name,response_fun){
	dataname.api_name = api_name;
	post('/Admin/Credit/hundre',dataname,response_fun,'json');
}

$('.cheattcation').click(function(){
	$('.jiazai').css('display','block');
	angdeapi(
		'cheattcation',
		function(response){
			$('.jiazai').css('display','none');
			var newp = $('<p class="cheat"></p>');
			if(response.success=='OK'){
				for(i in response.message){
					$(newp).html('欺诈分二点零'+' ('+response.message[i].scorecard_reason_code+')'+',次数:'+response.message[i].score);
					$('.cheattcation').after(newp);
					$('.cheattcation').remove();
				}
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
				$(newp).html(response.address+' ('+response.message+')');
				$('.cheattcation').after(newp);
				$('.cheattcation').remove();
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
	    });
});

$('.creditcation').click(function(){
	$('.jiazai').css('display','block');
	angdeapi(
		'creditcation',
		function(response){
			$('.jiazai').css('display','none');
			var newp = $('<p class="cheat"></p>');
			if(response.success=='OK'){
				if(response.message.decision == "PASS"){
					var passdec = "通过";
				}else{
					var passdec = response.message.decision;

				}
				$(newp).html('信用分数'+' ('+response.message.credit_score+',建议:'+passdec+')');
				$('.creditcation').after(newp);
				$('.creditcation').remove();
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
				$(newp).html(response.address+' ('+response.message+')');
				$('.creditcation').after(newp);
				$('.creditcation').remove();
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
			
	    });
});

$('.homeaddressverification').click(function(){
	$('.jiazai').css('display','block');
	angdeapi(
		'homeaddressverification',
		function(response){
			$('.jiazai').css('display','none');
			var newp = $('<p class="jiancxx"></p>');
			if(response.success=='OK'){
				$(newp).html(response.address+' ('+response.message+')');
				$('.homeaddressverification').after(newp);
				$('.homeaddressverification').remove();
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
				$(newp).html(response.address+' ('+response.message+')');
				$('.homeaddressverification').after(newp);
				$('.homeaddressverification').remove();
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
	    });
});

$('.companyaddressverification').click(function(){
	$('.jiazai').css('display','block');
	angdeapi('companyaddressverification',
		function(response){
			$('.jiazai').css('display','none');
			var newp = $('<p class="jiancxx"></p>');
			if(response.success=='OK'){
				$(newp).html(response.address+' ('+response.message+')');
				$('.companyaddressverification').after(newp);
				$('.companyaddressverification').remove();
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
				$(newp).html(response.address+' ('+response.message+')');
				$('.companyaddressverification').after(newp);
				$('.companyaddressverification').remove();
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
	    });
});

$('.phonewhenlong').click(function(){
	$('.jiazai').css('display','block');
	angdeapi('phonewhenlong',
		function(response){
			$('.jiazai').css('display','none');
			var newp = $('<p class="jiancxx"></p>');
			if(response.success=='OK'){
				$(newp).html(response.data);
				$('.phonewhenlong').after(newp);
				$('.phonewhenlong').remove();
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
	    });
});

$('.antifraud').click(function(){
	$('.jiazai').css('display','block');
	angdeapi('antifraud',
		function(response){
			$('.jiazai').css('display','none');
			var newp = $('<p class="jiancxx"></p>');
			if(response.success=='OK'){
				var yc = '';
				if(response.data){
					for (var i = 0; i < response.data.length; i++) {
						yc += response.data[i]+'<br />';
					}
				}
				$(newp).html(yc+'('+response.message+')');
				$('.antifraud').after(newp);
				$('.antifraud').remove();
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
	    });
});

$('.phonelist').click(function(){
	$('.jiazai').css('display','block');
	angdeapi('phonelist',
		function(response){
			$('.jiazai').css('display','none');
			if(response.success=='OK'){
				if($('.modal_t').attr('iscz')!='1' && response.data){
					for (var i = 0; i < response.data.length; i++) {
						$('.modal_k ul').append($('<li><label>'+response.data[i].name+'</label>  <span>'+response.data[i].phone+'</span></li>'));
					}
				}
				if(response.data.length<=0){
					sweetAlert("","没有获取到该用户的联系人列表！","warning");
				}else{
					$('.modal_t').css('display','block').attr('iscz','1');
				}
			}else if(response.success=='ERROR'&&response.error<10000){
				sweetAlert("",response.message,"warning");
			}else if(response.success=='ERROR'&&response.error>=10000){
				sweetAlert("",response.message,"warning");
			}
	    });
});
/**
 * 百融接口
 * @return {[type]} [description]
 */

//特殊名单验证
$('.specialList').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('specialList',function(response){
		if(response.success == 'OK'){
			$(".modle_div").show();
			$(".modle_div_l").show();
			$(".close_p_p").show();
			for( i in  response.hit){
				uicount++
				$(".uilist").append("<li>"+uicount+":"+response.hit[i]+"</li>");
			}
		}else if(response.success == 'ERROR'){
			 sweetAlert("",response.message,"warning");
			
		}
		
	});
});
//借贷意向验证
$('.loanIntention').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('loanIntention',function(response){
		if(response.success == 'OK'){
			$(".modle_div").show();
			$(".modle_div_l").show();
			$(".close_p_p").show();
			for( i in  response.hit){
				uicount++
				$(".uilist").append("<li>"+uicount+":"+response.hit[i]+"</li>");
			}
		}else if(response.success == "ERROR"){
			 sweetAlert("",response.message,"warning");
			// $(".modle_div").show();
			// $(".modle_div_l").show();
			// $(".close_p_p").show();
			// $(".uilist").append("<li>"+uicount+":"+response.message+"</li>");
		}
		
	});
});
//实名信息验证realNameInfo
$('.realNameInfo').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('realNameInfo',function(response){
		if(response.success == 'OK'){
			$(".modle_div").show();
			$(".modle_div_l").show();
			$(".close_p_p").show();
			for( i in  response.hit){
				uicount++
				$(".uilist").append("<li>"+uicount+":"+response.hit[i]+"</li>");
			}
		}else if(response.success == "ERROR"){
			 sweetAlert("",response.message,"warning");
		}
		
	});
});
//法院被执行人—个人版courtExecution
$('.courtExecution').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('courtExecution',function(response){
		if(response.success == 'OK'){
			$(".modle_div").show();
			$(".modle_div_l").show();
			$(".close_p_p").show();
			for( i in  response.hit){
				// uicount++
				$(".uilist").append("<li>"+response.hit[i]+"</li>");
			}
			// sweetAlert("",response.hit,"warning");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//支付消费信息识别—月度版
$('.payConsumption').click(function(){
	$(".uilist").find("li").remove();
	onehundredapi('payConsumption',function(response){
		if(response.success == 'OK'){
			$(".modle_div").show();
			$(".modle_div_l").show();
			$(".close_p_p").show();
			for( i in  response.hit){
				$(".uilist").append("<li>"+response.hit[i]+"</li>");
			}
			// sweetAlert("",response.hit,"warning");
		}else if(response.success == "ERROR"){
			 sweetAlert("",response.message,"warning");
		}
		
	});
});
//自然人识别badInfo
$('.badInfo').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('badInfo',function(response){
		if(response.success == 'OK'){
			if(response.hit){
				sweetAlert("",response.hit,"success");
			}else{
				sweetAlert("",response.message,"success");
			}
			
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//手机三要素简版—移动联通电信
$('.phoneEssential').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('phoneEssential',function(response){
		if(response.success == 'OK'){
			sweetAlert("",response.operation+':'+response.result,"success");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//学历查询
$('.educationInquiries').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('educationInquiries',function(response){
		if(response.success == 'OK'){
			swal({ 
			  title: "",
			  text: "<p>创建时间:"+response.operation.createDate+"<br/>学历:"+response.operation.educationDegree+"<br/>入学年:"+response.operation.enrolDate+"<br>毕业年:"+response.operation.graduateTime+"<br/>学校:"+response.operation.graduate+"<br/>学校类型:"+response.operation.schoolCategory+"<br/>学校城市:"+response.operation.schoolCity+"<br/>学校级别:"+response.operation.schoolTrade+"<br/>专业"+response.operation.specialityName+"<br/>是否毕业:"+response.operation.studyResult+"<br/>学历:"+response.operation.studyStyle+"</p>", 
			  html: true 
			});
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//身份证二要素
$('.identityVerific').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('identityVerific',function(response){
		if(response.success == 'OK'){
			sweetAlert("","身份证号与姓名"+response.message,"success");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//身份证二要素验证及照片查询
$('.identityVerificAndFind').click(function(){
	var uicount = 0;
	$(".uilist").find("li").remove();
	onehundredapi('identityVerificAndFind',function(response){
		if(response.success == 'OK'){
			sweetAlert("",response.message,"success");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//银行卡四要素验证
$('.bankFourPro').click(function(){
	$(".uilist").find("li").remove();
	onehundredapi('bankFourPro',function(response){
		if(response.success == 'OK'){
			sweetAlert("","身份证与银行卡:"+response.message,"success");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//telPeriod手机在网时长—移动联通电信		
$('.telPeriod').click(function(){
	$(".uilist").find("li").remove();
	onehundredapi('telPeriod',function(response){
		if(response.success == 'OK'){
			sweetAlert("","手机运营商:"+response.operation+"--手机在网时长:"+response.datavalue,"success");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//手机在网状态—移动联通电信		
$('.telStatus').click(function(){
	$(".uilist").find("li").remove();
	onehundredapi('telStatus',function(response){
		if(response.success == 'OK'){
			sweetAlert("","手机运营商:"+response.operation+"--手机在网状态:"+response.datavalue,"success");
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
//信用风险识别-线下现金分期
$('.scorelargecashv1').click(function(){
	$(".uilist").find("li").remove();
	onehundredapi('scorelargecashv1',function(response){
		if(response.success == 'OK'){
			// sweetAlert("","取值范围为300-1000分,分数越高代表客户偿还能力越好,违约概率越小:"+response.message,"warning");
			swal({ 
			  title:"该用户分数为:"+response.message,
			  text: "<p>取值范围为300-1000分,分数越高代表客户偿还能力越好,违约概率越小</p>", 
			  html: true 
			});
		}else if(response.success == "ERROR"){
			sweetAlert("",response.message,"warning");
		}
		
	});
});
function close_alert() {
	$('.modal_t').css('display','none');
}

$(".close_p_p").on("click",function(){
	$(".modle_div").hide();
	$(".modle_div_l").hide();
	$(".close_p_p").hide();
})

